#pragma once
#include "common.h"
#include "OGLDefs.h"

struct IEngineWindow;
typedef shared_ptr<IEngineWindow> IEngineWindowPtr;

#if defined _WIN32 || defined _WIN32 
	#define EGL_CONTEXT HGLRC
	#define EGL_DISPLAY HDC
	#define EGL_SURFACE void*
	#define EGL_CONFIG  void*
#elif defined X11 || defined __APPLE__
	#define EGL_CONTEXT CGLContextObj
	#define EGL_DISPLAY CGLPixelFormatObj
	#define EGL_SURFACE void*
	#define EGL_CONFIG  void*
#elif defined __ANDROID__
	#define EGL_CONTEXT EGLContext
	#define EGL_DISPLAY EGLDisplay
	#define EGL_SURFACE EGLSurface
	#define EGL_CONFIG  EGLConfig
#endif

struct EglSetup {
	uint32_t			RedBits;
	uint32_t			GreenBits;
	uint32_t 			BlueBits;
	uint32_t			AlphaBits;
	uint32_t 			DepthBits;
	uint32_t			StencilBits;
};

struct IEglWrapper {
public:
	IEglWrapper();
    virtual ~IEglWrapper() {};
	virtual EGL_CONTEXT CreateContext() = 0;
	virtual EGL_CONTEXT GetCurrentContext() = 0;
	virtual void DeleteContext(EGL_CONTEXT context) = 0;
	virtual void MakeCurrent(EGL_CONTEXT context) = 0;
	virtual void Present() = 0;
protected:
	EGL_DISPLAY m_display;
	EGL_SURFACE m_surface;
	EGL_CONFIG 	m_config;
};
typedef shared_ptr<IEglWrapper> EglWrapperPtr;

EglWrapperPtr CreateEglWrapper(const EglSetup& setup, IEngineWindowPtr window);